Skip to content

fix(runtime-shim): emit absolute proxy URLs using proxyBase#21

Merged
robbiebyrd merged 1 commit into
mainfrom
fix/shim-absolute-proxy-base
Jun 16, 2026
Merged

fix(runtime-shim): emit absolute proxy URLs using proxyBase#21
robbiebyrd merged 1 commit into
mainfrom
fix/shim-absolute-proxy-base

Conversation

@robbiebyrd

Copy link
Copy Markdown
Collaborator

Problem

The server-side url-rewriter emits absolute proxy URLs when proxyBase is set (commit 0b5ce10) so cross-origin-embedded pages resolve assets against the canonical proxy host. The client runtime shim never matched — it emitted root-relative /web/... paths that the browser resolves against the embedding/browsing host, leaking the wrong hostname for every runtime-built URL (fetch, XHR, element src/href, document.write, MutationObserver).

The earlier anti-double-wrap guard made it worse: it stripped proxyBase off already-absolute proxy URLs, demoting correct absolute URLs back to relative.

Fix

Mirror the server's buildProxyUrl: a proxify() helper prepends proxyBase to every emitted proxy path.

  • Already-absolute proxy URLs are left untouched (idempotent, no demotion).
  • Root-relative ones are upgraded to absolute when proxyBase is set.
  • When proxyBase is unset, output stays root-relative (backward-compatible direct-proxy default).

Notes

Secondary to Keeping-History/infra#9 (which corrects the PROXY_BASE_URL value). This change matters when a page is reached via a different host than PROXY_BASE_URL (cross-origin embed, or the box DNS).

Tests

Updated to assert the canonical-absolute contract. Full suite: 794 passing, typecheck clean, build OK.

🤖 Generated with Claude Code

The server-side url-rewriter emits absolute proxy URLs when proxyBase is
set (commit 0b5ce10) so cross-origin-embedded pages resolve assets
against the canonical proxy host. The client runtime shim never matched:
it emitted root-relative /web/... paths that the browser resolves against
the embedding/browsing host, leaking the wrong hostname for every
runtime-built URL (fetch, XHR, element src/href, document.write,
MutationObserver). The earlier anti-double-wrap guard made it worse by
stripping proxyBase off already-absolute proxy URLs, demoting correct
absolute URLs to relative.

Mirror buildProxyUrl: a proxify() helper prepends proxyBase to every
emitted proxy path. Already-absolute proxy URLs are left untouched
(idempotent, no demotion); root-relative ones are upgraded to absolute
when proxyBase is set. When proxyBase is unset, output stays
root-relative (backward-compatible direct-proxy default).

Tests updated to assert the canonical-absolute contract.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@robbiebyrd robbiebyrd merged commit ed98f00 into main Jun 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant